<?php
class Editor 
{
	/*
	 * 返回实例化Editor的HTML代码
	 *
	 * @param	string	$textarea_name: FORM表单里的编辑框的name属性名
	 * @param	string	$html_content : 编辑框里的内容 [可选]
	 * @param	array	$config       : 配置
	 *
	 * @return	string	html_code
	 */
	public static function build ($textarea_name, $init_content = NULL, $config = NULL)
	{
		$CKEditor = new CKEditor();

		$CKEditor->returnOutput = true;
		$CKEditor->basePath = _DOMAIN_SC_CDN_ . '/upload/sc/ckeditor/';

		// Set global configuration (will be used by all instances of CKEditor).
		if (is_array($config))
			$CKEditor->config = $config;

		if (! isset($CKEditor->config['width']))
			$CKEditor->config['width'] = 600;

		// Change default textarea attributes.
		$CKEditor->textareaAttributes = array("cols" => 80, "rows" => 10);

		// Create the first instance.
		return $CKEditor->editor($textarea_name, $init_content);
	}
}
